// functions -------------------------------------------------------------------
function nowdate(){
  $("span#hktime").html("北京时间：<b>"+now.getDate()+ "日" +(now.getHours())+":"+(now.getMinutes())+":"+(now.getSeconds()+"</b>"));
  now.setTime(now.getTime() + 1000);
  setTimeout("nowdate()",1000);
}

function countdown(){
    if (timestap >= 0) {
      timediff = timestap;
      days = Math.floor(timediff / (60 * 60 * 24)); 
    	timediff -= days * (60 * 60 * 24);
    	hours = Math.floor(timediff / (60 * 60));
    	timediff -= hours * (60 * 60);
    	mins = Math.floor(timediff / (60));
    	timediff -= mins * (60);
    	secs = Math.floor(timediff);
        
      str = " || 距离截止下注时间还有 ";
      if (days > 0 ) str += "<b>" + days + "</b> 天 ";
      if (hours > 0) str += "<b>" + hours + "</b> 小时 ";
      if (mins > 0) str += "<b>" + mins + "</b> 分钟 ";
      str += "<b>" + secs + "</b> 秒 ";
      $("span#countdownstr").html(str);
      setTimeout("countdown()",1000)
      if($("select#reflashtime").val() != 0){$(this).chgMinData();} // reflash time
      timestap-=1;
      if (timestap==0) {
          $().getAjaxDataAuto(_playtype, __roundID);
	    }
    } else {
        $("span#countdownstr").html("<font color=red><b>已经截止下注 !</b></font>");
    }
}

// jQuery Functions ------------------------------------------------------------
$.fn.getAjaxDataAuto = function(playtype, _lotto_id){
  //window.open('op.php?op=agent&fp=xmlBetTotal_3d&' + $("form#frmMenu").serialize());  
 $.getJSON('op.php?op=agent&fp=xmlBetTotal_3d&' + $("form#frmMenu").serialize() ,function(ratedata){
      var dataLen = 0;
      var urlPre = "";
      var hrefStr = "";
      if(ratedata.errormsg != undefined){
        $("div#errormsg").addClass("error").text("No Rate data");
      }else{
          if( myGlobalVal.jsFuname ){
            if(myGlobalVal.simple){ // 简易版
              switch(playtype){
                case 'r1': show_r1_n5s(_lotto_id, playtype, ratedata, _myHeader); break; // 双面盘&龙虎和
                case 'r1p': show_r1p_n5s(_lotto_id, playtype, ratedata, _myHeader); break; // 一字盘势
                case 'r1o': show_r1os(_lotto_id, playtype, ratedata, _myHeader); break; // 跨度
              }
            }
            else{                  
              switch(playtype){
                case 'r1': show_r1_n5(_lotto_id, playtype, ratedata, _myHeader); break;
                case 'r1p': show_r1p_n5(_lotto_id, playtype, ratedata, _myHeader); break;
                case 'r2': show_r2p_n5(_lotto_id, playtype, ratedata, _myHeader); break;
                case 'nn': show_nn(_lotto_id, playtype, ratedata, _myHeader); break;
				case 'sh': show_sh(_lotto_id, playtype, ratedata, _myHeader); break;
              }
            }
          }else{
            switch(playtype){
            case 'r1': show_r1(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2f': show_2face_n5(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r1p': show_r1p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2p': show_r2p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2': show_r2(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r2a': show_r2a(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'r3p': show_r3p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r3': show_r3(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r3a': show_r3a(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'g3': show_g3(_lotto_id, playtype, ratedata, _myHeader, true); break;
            case 'g6': show_g3(_lotto_id, playtype, ratedata, _myHeader, false); break;
            case 'rcmp': show_r3p(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r1pass': show_r1pass(_lotto_id, playtype, ratedata, _myHeader); break;
            case 'r1bs': show_r1bs(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'r1o': show_r1o(_lotto_id, playtype, ratedata, _myHeader2); break;
            case 'r1all': return; break;
            }
          }
          
          // set url
          $("span.span3da").click(function(){ $(this).setSpanAUrl(); });
          
          // show the menu bar for amount of each page
          $().showPgTotalAmount(ratedata.pgTotalAmountStr);

          // can change again
          $("form#frmMenu input").add("form#frmMenu select").removeAttr("disabled");
          
          // change tr color
          //$().chgTrColor();
      }
  });
};

$.fn.chgMinData = function(){
  tempMin = parseInt($("span#reflashtimeMin").text());
  if(tempMin == 0){
    $("input#btnReflash").click();
    $("span#reflashtimeMin").text(myGlobalVal.reloadCK);
  }else if(!$("select#reflashtime").attr("disabled")){
    $("span#reflashtimeMin").text(tempMin - 1);
  }
};

$.fn.chgTitleColorBlue = function(){$(".td15").removeClass("td15").addClass("td3");};
$.fn.chgTitleColorGray = function(){$(".td3").removeClass("td3").addClass("td15");};


// show the total bar
$.fn.showPgTotalAmount = function(oArr){
  var oTemp = "";
  var sTnD = new Date();
  var sTn = Math.round(sTnD.getTime() / 1000);
  for(x in oArr){
    oTemp = $('span#spanPageAmount' + oArr[x].idx ); 
    oTemp.text(oArr[x].amu);
    if( (oArr[x].tn > 0) && ((sTn - oArr[x].tn) < 30) ){
      oTemp.css({"background-color":"#FFFF99"});
    }else{
      oTemp.css({"background-color":""});
    }
  }
};  
// show the n/m url link
$.fn.setSpanAUrl = function(){
  var myid = $(this).attr("id").substr(4);
  var betdataArr = myid.split("_");
  var dates = $("input:hidden#dates").val();
  var datee = $("input:hidden#datee").val();
  var gametype = $("input:hidden#gametype").val();
  var lid = $("input:hidden#lotto_id_3d").val();
  var showUrl = '?op=agent&fp=betlist_3d&noback=1&bettype='+betdataArr[0]+'&subid=' + betdataArr[1] + '&num='+ betdataArr[2]+"&dates="+dates+"&datee="+datee+"&gametype="+gametype+"&lid="+lid;  
  //window.open(showUrl,'_self','scrollbars=yes');
  var oObj = document.getElementById("divRateRecord");
  oObj.innerHTML = "<div class='bgClc_" + gametype + "' align=right><input type='button' value='&nbsp;X&nbsp;' onclick='javascript:closeDiv();' class='c4'></div><iframe src='" + showUrl + "' width='100%' height='100%'></iframe><br />"; 
  oObj.className = "showRateRecord";
};

// -----------------------------------------------------------------------------
// print table functions
// -----------------------------------------------------------------------------
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
// 一字组合、佰定位、拾定位、个定位 都用此 function
function crt_0To9(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var str2 = "";
  var i = 0;
  var j = 0;
  var oObj = 0;
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class='td6 bigBottom' rowspan=2 " + setQuickUrl  + " >" + sTitle + "</th>";
  str += "<th class='span3dall bigBottom' align=center rowspan=2>" + rtotaldata.amount + "</th></th>";
  str2 += "<tr class='td2 bigBottom' align=center>";
  for(j = 0; j < 10; j = j + 2){
    i = j;
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class=td6 align=center>" + oObj.numbers + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    
    i = j + 1;
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str2 += "<th class=td6 align=center>" + oObj.numbers + "</th>";
    str2 += "<td class='" + oObj.bgclass + "'  align=center>" + oObj.rate + "";
    str2 += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  if(myGlobalVal.simple){
    str += "</tr>";
    str2 += "</tr>";
  }
  else{
    str += "<td></td><td></td><td></td></tr>";
    str2 += "<td></td><td></td><td></td></tr>";
  }
  
  return (str + str2);
}
function crt_0To5(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var oObj = 0;
  var arr=new Array("豹子","顺子","对子","半顺","杂六");
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class='td6 bigBottom' " + setQuickUrl  + " >" + sTitle + "</th>";
  str += "<th class='span3dall bigBottom' align=center>" + rtotaldata.amount + "</th></th>";
  for(j = 0; j < rdata.length; j ++){
    oObj = rdata[j];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class='span3da bigBottom' id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class='td6 bigBottom' align=center>" + arr[oObj.numbers] + "</th>";
    str += "<td class='" + oObj.bgclass + " bigBottom'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right class='bigBottom'><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  str += "</tr>";
  
  return (str);
}
function crt_nn(rdata, rtotaldata, rnum, bettype, subBettype, sTitle,arr){
  var str = "";
  var oObj = 0;
  var rowspan=(bettype==74?3:2);
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th rowspan="+rowspan+" class='td6 bigBottom' " + setQuickUrl  + " >" + sTitle + "</th>";
  str += "<th rowspan="+rowspan+" class='span3dall bigBottom' align=center>" + rtotaldata.amount + "</th></th>";
  for(j = 0; j < rdata.length; j ++){
    oObj = rdata[j];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class='span3da bigBottom' id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class='td6 bigBottom' align=center>" + arr[oObj.numbers] + "</th>";
    str += "<td class='" + oObj.bgclass + " bigBottom'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right class='bigBottom'><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  	if(j==4 || j==9) str+="</tr><tr>";
  }
  if(bettype==75) str+="<th class='bigBottom'></th><td class='bigBottom'></td><td class='bigBottom'></td>";
  str += "</tr>";
  
  return (str);
}
// 双面盘
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Array rtotaldata 总笔数与总下注额
// @param Array rnum tbody的ID
// @param Array bettype 玩法id, 例如一字组合传 0
// @param Array subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @param Array showTitleArr 玩法名称阵列
// @return String 表格字串
// --
// 佰定位-大小,单双,质合
// 拾定位-大小,单双,质合
// 个定位-大小,单双,质合
// 佰拾和数 , 佰个和数 , 拾个和数 – 单双
// 佰拾个和数 – 大小单双  
// 佰拾个和数尾数 OOO – 大小质合
function crt_2face_com(rdata, rtotaldata, rnum, bettype, subBettype, sTitle, showTitleArr){
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var idx = 0;          // 阵列index
  var tempI = 0;        // 1, 2 (大, 小)    
  var str = "";
  var strTitle = "";
  var oObj = "";
  var num = 0;
  var setBtnId = "";
  var nextI = -1;        // 可秀玩法
  var i = 0;
  var l = 0;
  var littletotal = 0;
  var classCount = 0;
  if(myGlobalVal.simple){ // 简易版
    if(bettype[0] == 5){ var nextMath = 3; }
    else{ var nextMath = 2; }
  }
  else{
    if(bettype[0] == 73){ var nextMath = 3; }
    else{ var nextMath = 2; }
  }
  for(i = 0, l = showTitleArr.length; i < l; i++ ){
    if(showTitleArr[i] == ""){ str += "<td></td><td></td><td></td>"; continue;} // 空白
    else{ nextI++; }
    tempI = nextI % nextMath;
    num = tempI + 1;
    idx = (nextI - tempI) / nextMath; 
    oObj = rdata[idx][tempI];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green" ;                                         // 输赢的颜色
    setSpanAUrl = "class=span3da id='url_" +  bettype[idx] + "_" + subBettype[idx] + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype[idx] + "_" + subBettype[idx] + "_" + oObj.numbers;
    
    str += "<th class=td6>" + showTitleArr[i] + "</th>";
    str += "<td id='td_r" + bettype[idx] +  "_" + subBettype[idx] + "_" + num + "' class='" + oObj.bgclass + "'>";
    str +=  oObj.rate + "<br />";
    str += "<span " + setSpanAUrl + " >" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype[idx] + "_" + subBettype[idx] + "[]' value='"+oObj.numbers+"' />";
    str += "</td>";  
    str += "<td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    if(oObj.bgclass != "") classCount = "namount";                          
  }
  // count little total
  for(i = 0, l = rtotaldata.length; i < l; i++){
    littletotal += rtotaldata[i].amount - 0;
  }
  
  strTitle += "<tr class='td2 bigBottom' align=center><th class=td6>" + sTitle + "</th>";
  strTitle += "<th class='span3dall " + classCount + "'>" + littletotal + "</th>";
  
  return strTitle + str;

}

// 万千和数 – 单双  - (五码才有)
// 万佰和数 – 单双  - (五码才有)
// 万拾和数 – 单双  - (五码才有)
// 万个和数 – 单双  - (五码才有)
// 千佰和数 – 单双  - (五码才有)
// 千拾和数 – 单双  - (五码才有)
// 千个和数 – 单双  - (五码才有)
// 佰拾和数 – 单双  - (五码才有)
// 佰个和数 – 单双  - (五码才有)
// 拾个和数 – 单双  - (五码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_2face_a_S(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var i = 0;
  var oObj = 0;
  var strArr = ['', '单', '双'];
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6>" + sTitle + "</th>";
  str += "<th class=span3dall align=center>" + rtotaldata.amount + "</th>";
  for(i = 0; i < 2; i++){
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'";
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    str += "<th class=td6 align=center>" + strArr[oObj.numbers] + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  str += "</tr>";
  return str;
}

// ※ 二字定位 - (三码才有)
// 	佰拾 – 00 ~ 99 - (三码才有)
// 	佰个 – 00 ~ 99 - (三码才有)
// 	拾个 – 00 ~ 99 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @param String iNumTr tr列数
// @return String 表格字串
function crt_2p(rdata, rtotaldata, rnum, bettype, subBettype, sTitle, iNumTr){
  var str = "";
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var htmlTemp = '<tr class="td2" align="right">';
  var htmlTitle = '<th>号码</th><th>笔数</th><th>金额</th><th>输赢</th><th>补货</th><th>赔率</th><th>操盘</th>';
  var trArr = new Array();
  var idx = 0;
  var dataLen = rdata.length;
  var i = 0;                
  for(i = 0; i < iNumTr; i++){ trArr[i] = '';} 
  var oObj = 0;              
            
  str += '<caption class="td0 bgClc_' + myGlobalVal.gametype  + '">' + sTitle + '</caption>';
  str += '<thead><tr class="td15">' +  htmlTitle + htmlTitle + htmlTitle + htmlTitle + htmlTitle + '</tr></thead>';
  str += '<tbody>';
  for(i = 0; i < dataLen; i++){
    idx = i % iNumTr;
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    trArr[idx] += "<th class=td6 align=center>" + oObj.numbers + "</th>";
    trArr[idx] += "<td>" + oObj.totalnum + "</td>"; 
    trArr[idx] += "<td class='" + oObj.bgclass + "'><span " + setSpanAUrl + ">" + oObj.amount + "</span></td>";
    trArr[idx] += "<td nowrap class='jsbo'><font color=" + winlostStr + ">" + oObj.winlost + "</font></td><td>&nbsp;</td>";
    trArr[idx] += "<td class='rate_th2'>" + oObj.rate + "</td>";
    trArr[idx] += "<td align=center><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td>";
  }
  str += htmlTemp + trArr.join('</tr><tr class=td2 align=right>') + '</tr>'; 
  return str;
}

// ※ 二字和数 - (三码才有)
// 	佰拾和数 – 0 ~ 18 - (三码才有)
// 	佰个和数 – 0 ~ 18 - (三码才有)
// 	拾个和数 – 0 ~ 18 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_2p_a_0To18(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var i = 0;
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var oObj = 0;
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "' class='titleTypeBtnClick'";
  var showNum = "";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6 rowspan=2 " + setQuickUrl + ">" + sTitle + "</th>";
  str += "<th class=span3dall align=center rowspan=2>" + rtotaldata.amount + "</th></th>";
   
  for(i = 0; i < 11; i++){
    oObj = rdata[i];
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    if(i == 5){ str += "<td></td><td></td><td></td></tr><tr class=td2 align=center>" ;}
    if(oObj.numbers < 5) {showNum = "0~4";}
    else if(oObj.numbers > 13) {showNum = "14~18";}
    else {showNum = oObj.numbers; } 
    str += "<th class=td6 align=center>" + showNum + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
  }
  str += "</tr>";
  return str;
}

// ※ 二字和数
// 	佰拾和数尾数 – 0尾 ~ 9尾 - (三码才有)
// 	佰个和数尾数 – 0尾 ~ 9尾 - (三码才有)
//   拾个和数尾数 – 0尾 ~ 9尾 - (三码才有)
// ※ 三字和数
//   佰拾个和数尾数OOO 0~9 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @param String sNumStr 号码尾字
// @return String 表格字串
function crt_a_0To9(rdata, rtotaldata, rnum, bettype, subBettype, sTitle, sNumStr){
  var str = "";
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  var i = 0;
  var oObj = 0;
  str += "<tr class='td2' align=center id=thr" + rnum + "><th class=td6 rowspan=2 " + setQuickUrl + ">" + sTitle + "</th>";
  str += "<th class=span3dall align=center rowspan=2>" + rtotaldata.amount + "</th></th>";
   
  for(i = 0; i < 10; i++){
    oObj = rdata[i]; 
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    if(i == 5){ str += "<td></td><td></td><td></td></tr><tr class=td2 align=center>" ;}
    
    str += "<th class=td6 align=center>" + oObj.numbers + sNumStr + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    
  }
  str += "<td></td><td></td><td></td></tr>";
  return str;


}

// ※ 三字和数
// 	百拾个和数OOO  0~27  - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_3_a(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var i = 0;
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var preNum = "";
  var setQuickUrl = " id='url_" +  bettype + "_" + subBettype + "'";
  var oObj = 0;
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6 rowspan=3 "+ setQuickUrl +">" + sTitle + "</th>";
  str += "<th class=span3dall align=center rowspan=3>" + rtotaldata.amount + "</th></th>";
   
  for(i = 0; i < 16; i++){
    oObj = rdata[i];
    if(i > 0){preNum = oObj.numbers;}
    else { preNum = "0~6"; }
    if(i > 14){ preNum = "21~27"; }

    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
    setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    if(i > 0 && (i % 6 == 0)){ str += "</tr><tr class=td2 align=center>" ;}
    
    str += "<th class=td6 align=center>" + preNum + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";
    
  }
  str += "<td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  return str;

}


// ※ 组选三
// 	前三 – 5,6,7,8,9
// 	中三 – 5,6,7,8,9
// 	后三 – 5,6,7,8,9
// ※ 组选六
// 	前三 – 4,5,6,7,8
// 	中三 – 4,5,6,7,8
// 	后三 – 4,5,6,7,8
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_g(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var str = "";
  var dataLen = rdata.length;
  var i = 0; 
  var oObj = 0;
  var setBtnId = "";
  var setSpanAUrl = "";
  str += "<table class='tblMy3D' width='100%'><thead><tr class='td15'><th>号码</th><th>笔数</th><th>金额</th><th>赔率</th><th>操盘</th></tr></thead>";
  str += "<tbody>";
  if(bettype == 29){    
    for(i = 0; i < dataLen ; i++){
      oObj = rdata[i];
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
      str += "<tr class='td2' align='right'><th class='td6' align='center'>全包</th><td>" + oObj.totalnum + "</td>";
      str += "<td class='" + oObj.bgclass + "'><span" + setSpanAUrl + ">" + oObj.amount + "</span></td>";
      str += "<td class='rate_th2'>" + oObj.rate + "</td>";
      str += "<td align='center'><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td></tr>";
    }   
  }else{
    for(i = 0; i < dataLen ; i++){
      oObj = rdata[i];      
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结                    
      str += "<tr class='td2' align='right'><th class='td6' align='center'>" + oObj.numbers + "</th><td>" + oObj.totalnum + "</td>";
      str += "<td class='" + oObj.bgclass + "'><span" + setSpanAUrl + ">" + oObj.amount + "</span></td>";
      str += "<td class='rate_th2'>" + oObj.rate + "</td>";
      str += "<td align='center'><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td></tr>";
    }   
  
  }
  str += "</tbody>";
  str += "<tfoot align='right'><tr class='td6' align='right'><th class='td0 bgClc_" + myGlobalVal.gametype + "'>合计</th><td>" + rtotaldata.totalnum + "</td><td>" + rtotaldata.amount + "</td><td>--</td><td>--</td></tr></tfoot>";
  str += "</table>";
  return str;
}

// ※ 一字过关
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_1pass(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){
  var titleArr = [['大', '小'], ['单', '双'], ['质', '合']];
  var i = 0;
  var j = 0;
  var k = 0;
  var strTbl = "";
  var winlostStr = "";
  var setBtnId = "";
  var setSpanAUrl = "";
  for(i = 0; i < 3; i++ ){
    strTbl += "<tr>";
    for(j = 0; j < 3; j++){
      k = (6 * j) + (i * 2);
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + rdata[k].numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + rdata[k].numbers + "'"; // 笔数与金额的连结

      winlostStr = ( rdata[k].winlost < 0 ) ? "#FF00FF" : "green";
      strTbl += "<th class='td6'>" + titleArr[i][0] + "</th>"; // "<td class='betnum' id='td_r46_" + k + "'>&nbsp;</td><td id='td_wl_r46_" + k + "' align='right'>&nbsp;</td>";
      strTbl += "<td class='" + rdata[k].bgclass + "'  align=center>" + rdata[k].rate ;
      strTbl += "<br /><span " + setSpanAUrl + ">" + rdata[k].totalnum + "/" + rdata[k].amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+rdata[k].numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + rdata[k].winlost + "</font></td>";
      
      k += 1;
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + rdata[k].numbers;
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + rdata[k].numbers + "'"; // 笔数与金额的连结

      winlostStr = ( rdata[k].winlost < 0 ) ? "#FF00FF" : "green";
      strTbl += "<th class='td6'>" + titleArr[i][1] + "</th>"; // "<td class='betnum' id='td_r46_" + k + "'>&nbsp;</td><td id='td_wl_r46_" + k + "' align='right'>&nbsp;</td>";
      strTbl += "<td class='" + rdata[k].bgclass + "'  align=center>" + rdata[k].rate ;
      strTbl += "<br /><span " + setSpanAUrl + ">" + rdata[k].totalnum + "/" + rdata[k].amount + "</span><br /><input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+rdata[k].numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + rdata[k].winlost + "</font></td>";
      
    }
    strTbl += "</tr>";
  }
  return strTbl;
}

// ※ 其他 - 豹子 顺子 对子 半顺 杂六 - (三码才有)
// @param Array rdata xmlBetTotal_3d回传之资料
// @param Object rtotaldata 总笔数与总下注额
// @param String rnum tbody的ID
// @param Int bettype 玩法id, 例如一字组合传 0
// @param Int subBettype 玩法 前三中三后三, 例如一字组合前三传 0,无分亦传0
// @param String sTitle 表头名称
// @return String 表格字串
function crt_o(rdata, rtotaldata, rnum, bettype, subBettype, sTitle){

  var str = "";
  var i = 0;
  var winlostStr = "";
  var setSpanAUrl = "";
  var setBtnId = "";
  var titleArr = ["豹子", "顺子", "对子", "半顺", "杂六"];
  var oObj = "";
  str += "<tr class=td2 align=center id=thr" + rnum + "><th class=td6>"+ sTitle +"</th>";
  if(myGlobalVal.simple){str += "<th class=span3dall align=center>" + rtotaldata.amount + "</th></th>";}
  else{str += "<th class=span3dall align=center>" + rtotaldata[0].amount + "</th></th>";}
   
  for(i = 0; i < 5; i++){
    if(myGlobalVal.simple){oObj = rdata[i];}
    else{oObj = rdata[i][0];}
    winlostStr = ( oObj.winlost < 0 ) ? "#FF00FF" : "green";
    if(myGlobalVal.simple){
      setSpanAUrl = " class=span3da id='url_" +  bettype + "_" + subBettype + "_" + oObj.numbers + "'"; // 笔数与金额的连结
      setBtnId = "b_"+  bettype + "_" + subBettype + "_" + oObj.numbers;
    }
    else{
      setSpanAUrl = " class=span3da id='url_" +  bettype[i] + "_" + subBettype[i] + "_" + oObj.numbers + "'"; // 笔数与金额的连结
      setBtnId = "b_"+  bettype[i] + "_" + subBettype[i] + "_" + oObj.numbers;
    }
    str += "<th class=td6 align=center>" + titleArr[i] + "</th>";
    str += "<td class='" + oObj.bgclass + "'  align=center>" + oObj.rate ;
    str += "<br /><span " + setSpanAUrl + ">" + oObj.totalnum + "/" + oObj.amount + "</span><br />";
    if(myGlobalVal.simple){str += "<input type='checkbox' name='unow"+ bettype + "_" + subBettype+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";}
    else{str += "<input type='checkbox' name='unow"+ bettype[i] + "_" + subBettype[i]+"[]' value='"+oObj.numbers+"' /></td><td align=right><font color=" + winlostStr + ">" + oObj.winlost + "</font></td>";}   
  }
  if(myGlobalVal.simple){str += "</tr>";}
  else{str += "<td></td><td></td><td></td></tr>";}
  return str;
}

// 补货计算
function crt_bo1(){
  var str = "";
  str += "补货赔率: <input name='bo1' id='bo1' value='42' size=3>　最大输值: <input name='bo2' id='bo2' value='-200000' size='8'>　<input type='button' value='补货计算' id='btnCountBo' /> 　　　　　　";
  return str;
}

// 切换前三后三中三按钮
function btnChgSubId(subid){
  $("form#frmMenu input#subid").val(subid);
  $("input#btnReflash").click();
}

// 产生前中后按钮
function crt_btnSubid(subid, mainTitle){
  var strTbl = "";
  var subTitle = ['后三', '中三', '前三']
  var subClass = 'colorBtnGray';
  strTbl += "<div>";
  for(i = 2; i > -1; i--){
    if(i == subid){subClass = 'c1'; }
    else{ subClass = 'colorBtnGray'; }
    strTbl += "<input type='button' onclick='javascript:btnChgSubId(" + i + ");' value='" + subTitle[i] + "◎" + mainTitle + "' class='" + subClass + "' />";
  }
  strTbl += "</div>";
  return strTbl;
  
}

// 切换 bid
function chgBid(bid){
  var bidStr = bid.toString();
  $('form#frmMenu input#bid').val(bid);
  $("input#btnReflash").click();
}


// -----------------------------------------------------------------------------
// 玩法呼叫的function 
// -----------------------------------------------------------------------------
  
// 主盘势    
function show_r1(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  var rArr = "";
  var rArrA = "";
  var betArr = "";
  var showTitleArr = "";
  
  //	一字组合
  strTbl += crt_0To9(ratedata.r0_0, ratedata.r0_0total, "", 0, 0, '一字组合');
                       
  // 佰定位-大小,单双,质合
  showTitleArr = ['大', '小', '单', '双', '质', '合'];
  strTbl += crt_2face_com([ratedata.r4_0 , ratedata.r7_0 , ratedata.r10_0]
                        , [ratedata.r4_0total, ratedata.r7_0total, ratedata.r10_0total]
                        , "", [4, 7, 10], [0,0,0], '佰定位', showTitleArr);

  // 拾定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r5_0, ratedata.r8_0, ratedata.r11_0]
                         , [ratedata.r5_0total, ratedata.r8_0total,ratedata.r11_0total]
                         , "", [5, 8, 11], [0,0,0], '拾定位', showTitleArr);
  
  // 个定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r6_0, ratedata.r9_0, ratedata.r12_0]
                         , [ratedata.r6_0total, ratedata.r9_0total,ratedata.r12_0total]
                         , "", [6, 9, 12], [0,0,0], '个定位', showTitleArr);
  
  // 佰拾和数 , 佰个和数 , 拾个和数 – 单双
  showTitleArr = ['', '', '单', '双', '', ''];
  strTbl += crt_2face_com([ratedata.r17_0], [ratedata.r17_0total], "", [17], [0], '佰拾和数 OOX', showTitleArr);
  strTbl += crt_2face_com([ratedata.r18_0], [ratedata.r18_0total], "", [18], [0], '佰个和数 OXO', showTitleArr);
  strTbl += crt_2face_com([ratedata.r19_0], [ratedata.r19_0total], "", [19], [0], '拾个和数 XOO', showTitleArr);
  
  
  // 佰拾个和数 – 大小单双
  strTbl += crt_2face_com([ratedata.r22_0 , ratedata.r23_0]
                        , [ratedata.r22_0total, ratedata.r23_0total]
                        , "", [22, 23], [0, 0], '佰拾个和数 OOO', ['大', '小', '单', '双', '', '']);
  
  // 佰拾个和数尾数 OOO – 大小质合
  strTbl += crt_2face_com([ratedata.r44_0 , ratedata.r45_0]
                        , [ratedata.r44_0total, ratedata.r45_0total]
                        , "", [44, 45], [0, 0], '佰拾个和数尾数 OOO ', ['尾大', '尾小', '', '', '尾质', '尾合']);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}


// 一字组合 - 五码
function show_r1_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  
  //	全五字组合
  strTbl += crt_0To9(ratedata.r55_0, ratedata.r55_0total, "", 55, 0, '全五一字组合');
  
  // 一字组合 - 前中后
  strTbl += crt_0To9(ratedata.r0_2, ratedata.r0_2total, "", 0, 2, '前三一字组合');
  strTbl += crt_0To9(ratedata.r0_1, ratedata.r0_1total, "", 0, 1, '中三一字组合');
  strTbl += crt_0To9(ratedata.r0_0, ratedata.r0_0total, "", 0, 0, '后三一字组合');
  
  // N定位-大小,单双,质合
  var showTitleArr = ['大', '小', '单', '双', '质', '合'];
  var showTitleArr2 = ['总大', '总小', '总单', '总双', '', ''];
  var showTitleArr3 = ['龙', '虎', '和', '', '', ''];
  // 万定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r56_0 , ratedata.r57_0 , ratedata.r58_0]
                        , [ratedata.r56_0total, ratedata.r57_0total, ratedata.r58_0total]
                        , "", [56, 57, 58], [0,0,0], '第一球OXXXX', showTitleArr);

  // 千定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r59_0 , ratedata.r60_0 , ratedata.r61_0]
                        , [ratedata.r59_0total, ratedata.r60_0total, ratedata.r61_0total]
                        , "", [59, 60, 61], [0,0,0], '第二球XOXXX', showTitleArr);
  
  // 佰定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r4_0 , ratedata.r7_0 , ratedata.r10_0]
                        , [ratedata.r4_0total, ratedata.r7_0total, ratedata.r10_0total]
                        , "", [4, 7, 10], [0,0,0], '第三球XXOXX', showTitleArr);

  // 拾定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r5_0, ratedata.r8_0, ratedata.r11_0]
                         , [ratedata.r5_0total, ratedata.r8_0total,ratedata.r11_0total]
                         , "", [5, 8, 11], [0,0,0], '第四球XXXOX', showTitleArr);
  
  // 个定位-大小,单双,质合
  strTbl += crt_2face_com([ratedata.r6_0, ratedata.r9_0, ratedata.r12_0]
                         , [ratedata.r6_0total, ratedata.r9_0total,ratedata.r12_0total]
                         , "", [6, 9, 12], [0,0,0], '第五球XXXXO', showTitleArr);
  
  // 总和-大小,单双
  strTbl += crt_2face_com([ratedata.r72_0, ratedata.r71_0]
                         , [ratedata.r72_0total, ratedata.r71_0total]
                         , "", [72, 71], [0,0], '总和', showTitleArr2);
  // 龙虎
  strTbl += crt_2face_com([ratedata.r73_0]
                         , [ratedata.r73_0total]
                         , "", [73], [0], '龙虎和', showTitleArr3);
  
  
  $("#myDivTbl").html(strTbl);
}

// 双面盘口  
function show_2face_n5(_lotto_id, playtype, ratedata, _myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  strTbl += crt_2face_a_S(ratedata.r62_0, ratedata.r62_0total, '0', 62, 0, '万千和数 OOXXX');
  strTbl += crt_2face_a_S(ratedata.r63_0, ratedata.r63_0total, '0', 63, 0, '万佰和数 OXOXX');
  strTbl += crt_2face_a_S(ratedata.r64_0, ratedata.r64_0total, '0', 64, 0, '万拾和数 OXXOX');
  strTbl += crt_2face_a_S(ratedata.r65_0, ratedata.r65_0total, '0', 65, 0, '万个和数 OXXXO');
  strTbl += crt_2face_a_S(ratedata.r66_0, ratedata.r66_0total, '0', 66, 0, '千佰和数 XOOXX');
  strTbl += crt_2face_a_S(ratedata.r67_0, ratedata.r67_0total, '0', 67, 0, '千拾和数 XOXOX');
  strTbl += crt_2face_a_S(ratedata.r68_0, ratedata.r68_0total, '0', 68, 0, '千个和数 XOXXO');
  strTbl += crt_2face_a_S(ratedata.r17_0, ratedata.r17_0total, '0', 17, 0, '佰拾和数 XXOOX');
  strTbl += crt_2face_a_S(ratedata.r18_0, ratedata.r18_0total, '0', 18, 0, '佰个和数 XXOXO');
  strTbl += crt_2face_a_S(ratedata.r19_0, ratedata.r19_0total, '0', 19, 0, '拾个和数 XXXOO');
  $("#myDivTbl").html(strTbl);
}

// 一字盘势  
function show_r1p(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  strTbl += crt_0To9(ratedata.r1_0, ratedata.r1_0total, "", 1, 0, '佰定位OXX');
  strTbl += crt_0To9(ratedata.r2_0, ratedata.r2_0total, "", 2, 0, '拾定位XOX');
  strTbl += crt_0To9(ratedata.r3_0, ratedata.r3_0total, "", 3, 0, '个定位XXO');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

function show_r1p_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader;
  strTbl += crt_0To9(ratedata.r69_0, ratedata.r69_0total, "", 69, 0, '第一球OXXXX');
  strTbl += crt_0To9(ratedata.r70_0, ratedata.r70_0total, "", 70, 0, '第二球XOXXX');
  strTbl += crt_0To9(ratedata.r1_0, ratedata.r1_0total, "", 1, 0, '第三球XXOXX');
  strTbl += crt_0To9(ratedata.r2_0, ratedata.r2_0total, "", 2, 0, '第四球XXXOX');
  strTbl += crt_0To9(ratedata.r3_0, ratedata.r3_0total, "", 3, 0, '第五球XXXXO');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}     
function show_r2p_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += "<tr class='td0 bgClc_12'><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>'";
  // 其它 - 前中后
  strTbl += crt_0To5(ratedata.r76_2, ratedata.r76_2total, "", 76, 2, '前三其它');
  strTbl += crt_0To5(ratedata.r76_1, ratedata.r76_1total, "", 76, 1, '中三其它');
  strTbl += crt_0To5(ratedata.r76_0, ratedata.r76_0total, "", 76, 0, '后三其它');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}                  
function show_nn(_lotto_id, playtype, ratedata, myHeader){
   var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += "<tr class='td0 bgClc_12'><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>'";
  strTbl += crt_nn(ratedata.r74_0, ratedata.r74_0total, "", 74, 0, '牛牛',new Array("牛1","牛2","牛3","牛4","牛5","牛6","牛7","牛8","牛9","牛牛","牛大","牛小","无牛","牛单","牛双"));
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
function show_sh(_lotto_id, playtype, ratedata, myHeader){
   var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += "<tr class='td0 bgClc_12'><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>'";
  strTbl += crt_nn(ratedata.r75_0, ratedata.r75_0total, "", 75, 0, '梭哈',new Array("五条","四条","葫芦","顺子","三条","两对","单对","散号"));
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
// 二字定位  
function show_r2p(_lotto_id, playtype, ratedata, myHeader){
  
  var strTbl = "";
  var i = 0;
  var bid = $("form#frmMenu input#bid").val();
  var btnArr = [14,15,16];
  var btnTitleArr = ['佰拾定位OOX', '佰个定位OXO', '拾个定位XOO'];
  var btnVal = "";
  var btnTitleVal = "";
  var classEND = "";
  // 切换按钮
  strTbl += "<div id='chgBtnGroup'>";
  for(i = 0; i < 3; i++){
    btnVal = btnArr[i];
    btnTitleVal = btnTitleArr[i];
    if(btnVal == bid){ classEND = "d"; }
    else{ classEND = ""; } 
    strTbl += "<input type='button' id='chgr" +  btnArr[i] + "' onclick='javascript:chgBid([" + btnVal + "])' class='btnchoice" + classEND + "' value='" + btnTitleVal + "' />";
  }
  strTbl += "</div>";
  
  // 开将画表格
  strTbl += "<table class='tblMy3D' width='100%' >";
  switch(bid){
    case '14': strTbl += crt_2p(ratedata.r14_0, ratedata.r14_0total, "", 14, 0, '佰拾定位OOX', 20); break;
    case '15': strTbl += crt_2p(ratedata.r15_0, ratedata.r15_0total, "", 15, 0, '佰个定位OOX', 20); break;
    case '16': strTbl += crt_2p(ratedata.r16_0, ratedata.r15_0total, "", 16, 0, '拾个定位OOX', 20); break;
    default: $("#myDivTbl").text('error -999'); return false;
  }
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
  
}

// 二字组合  
function show_r2(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='100%' >";  
  strTbl += crt_2p(ratedata.r13_0, ratedata.r13_0total, "", 13, 0, '二字不定位', 11);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

function show_r2_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  var subid = $("form#frmMenu input#subid").val();
  var subTitle = ['后三', '中三', '前三']
  var i = 0;
  
  // 显示前三 中三 后三 按钮
  strTbl += crt_btnSubid(subid, '二字不定位');
  strTbl += "<table class='tblMy3D' width='100%' >";
  switch(subid){
    case '0': strTbl += crt_2p(ratedata.r13_0, ratedata.r13_0total, "", 13, 0, subTitle[subid] + '◎二字不定位', 11); break;
    case '1': strTbl += crt_2p(ratedata.r13_1, ratedata.r13_1total, "", 13, 1, subTitle[subid] + '◎二字不定位', 11); break;
    case '2': strTbl += crt_2p(ratedata.r13_2, ratedata.r13_2total, "", 13, 2, subTitle[subid] + '◎二字不定位', 11); break;
    default: return;
  }
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 二字和数  
function show_r2a(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  
  var i = 0;
  var bid = $("form#frmMenu input#bid").val();
  var btnArr = ['36,39','37,40','38,41'];
  var btnTitleArr = ['佰拾和数OOX', '佰个和数OXO', '拾个和数XOO'];
  var btnVal = "";
  var btnTitleVal = "";
  var classEND = "";
  var showId = 0;
  var showTitle = "";
  // 切换按钮
  strTbl += "<div id='chgBtnGroup'>";
  for(i = 0; i < 3; i++){
    btnVal = btnArr[i];
    btnTitleVal = btnTitleArr[i];
    if(btnVal == bid){ classEND = "d";  showId = i;}
    else{ classEND = ""; } 
    strTbl += "<input type='button' onclick='javascript:chgBid([" + btnVal + "])' class='btnchoice" + classEND + "' value='" + btnTitleVal + "' />";
  }
  showTitle = btnTitleArr[showId];
  strTbl += "</div>";
  strTbl += "<table class='tblMy3D' width='100%' >";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>" + showTitle + "</caption>";
  strTbl += myHeader;
  switch(showId){
    case 0:
      strTbl += crt_2p_a_0To18(ratedata.r36_0, ratedata.r36_0total, "", 36, 0, showTitle);
      strTbl += myHeader;
      strTbl += crt_a_0To9(ratedata.r39_0, ratedata.r39_0total, "", 39, 0, showTitle, "尾");
      break;
    case 1:
      strTbl += crt_2p_a_0To18(ratedata.r37_0, ratedata.r37_0total, "", 37, 0, showTitle);
      strTbl += myHeader;
      strTbl += crt_a_0To9(ratedata.r40_0, ratedata.r40_0total, "", 40, 0, showTitle, "尾");
      break;
    case 2:
      strTbl += crt_2p_a_0To18(ratedata.r38_0, ratedata.r38_0total, "", 38, 0, showTitle);
      strTbl += myHeader;
      strTbl += crt_a_0To9(ratedata.r41_0, ratedata.r41_0total, "", 41, 0, showTitle, "尾");
      break;
    default: $("#myDivTbl").text('error -998'); return false;
  }
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 三字定位  
// 复式组合
function show_r3p(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  var sTitle = "";
  var oObj = "";
  var bettype = 21;
  if( playtype == 'rcmp' ){ 
    sTitle = "复式组合";
    oObj = ratedata.r35_0;
    oObj_total = ratedata.r35_0total;
    bettype = 35;
  }else{
    sTitle = "三字定位(佰拾个定位)";
    oObj = ratedata.r21_0;
    oObj_total = ratedata.r21_0total;
    bettype = 21;
  }
  strTbl += "<table class='tblMy3D' width='100%' >";
  strTbl += crt_2p(oObj, oObj_total, "", bettype, 0, sTitle, 20);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 三字组合  
function show_r3(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='100%' >";
  strTbl += crt_2p(ratedata.r20_0, ratedata.r20_0total, "", 20, 0, '三字组合(三字不定位)', 22);
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
// 三字组合5 码版
function show_r3_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  var subid = $("form#frmMenu input#subid").val();
  
  strTbl += crt_btnSubid(subid, '三字不定位');
  strTbl += "<table class='tblMy3D' width='100%' >";
  switch(subid){
    case '0': strTbl += crt_2p(ratedata.r20_0, ratedata.r20_0total, "", 20, 0, '后三◎三字组合(三字不定位)', 22); break;
    case '1': strTbl += crt_2p(ratedata.r20_1, ratedata.r20_1total, "", 20, 1, '中三◎三字组合(三字不定位)', 22); break;
    case '2': strTbl += crt_2p(ratedata.r20_2, ratedata.r20_2total, "", 20, 2, '前三◎三字组合(三字不定位)', 22); break;
    default: return;
  }
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 三字和数  
function show_r3a(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990' >";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>三字和数</caption>";
  strTbl += myHeader;
  strTbl += crt_3_a(ratedata.r42_0, ratedata.r42_0total, "", 42, 0, '百拾个和数OOO');
  strTbl += myHeader;
  strTbl += crt_a_0To9(ratedata.r43_0, ratedata.r43_0total, "", 43, 0, '佰拾个和数尾数OOO', "尾");
  $("#myDivTbl").html(strTbl);
}

// 组选三   
// 组选六 
function show_g3(_lotto_id, playtype, ratedata, myHeader, g3Flag){
  var strTbl = "";
  var showArr = "";
  var j = 0;
  var i = 0;
  var oObj = "";
  var oObj_total = "";
  var addNum = 0;
  var sTitle = "";
  var setQuickUrl = "";
  if(g3Flag){
    showArr = [24, 25, 26, 27, 28, 29];
    addNum = 5;
    sTitle = "组选三";
  }else{
    showArr = [30, 31, 32, 33, 34];
    addNum = 4;
    sTitle = "组选六";
  }
  var dataLeng = showArr.length;
  strTbl += "<table style='border: 1px solid #c8c8c8;' width='100%'>";
  //strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>" + sTitle + "</caption>";
  strTbl += "<tr class='title0 bgImg_" + myGlobalVal.gametype + "' id='titletype'>";
  for(i = 0; i < dataLeng; i++){
    j = i + addNum;
    setQuickUrl = " id='url_" +  showArr[i] + "_0'";
    if( j < 10 ) { strTbl += "<th "+ setQuickUrl +" class='titleTypeBtnClick'>&nbsp;" + j + "&nbsp;</th>"; }
    else { strTbl += "<th>全包</th>"; }
  }
  strTbl += "</tr>";
  strTbl += "<tr>";
  
  for(i = 0; i < dataLeng; i++ ){
    oObj = eval("ratedata.r" + showArr[i] + "_0");
    oObj_total = eval("ratedata.r" + showArr[i] + "_0total");
    strTbl += "<td valign='top'>";
    strTbl += crt_g(oObj, oObj_total, "", showArr[i], 0, showArr[i]);
    strTbl += "</td>";
  }
  strTbl += "</tr></table>";
  $("#myDivTbl").html(strTbl);
}

function show_g3_n5(_lotto_id, playtype, ratedata, myHeader, g3Flag){
  var subid = $("form#frmMenu input#subid").val();
  var strTbl = "";
  var showArr = "";
  var j = 0;
  var i = 0;
  var oObj = "";
  var oObj_total = "";
  var addNum = 0;
  var sTitle = "";
  var subTitle = ['后三', '中三', '前三']
  if(g3Flag){
    showArr = [24, 25, 26, 27, 28, 29];
    addNum = 5;
    sTitle = "组选三";
  }else{
    showArr = [30, 31, 32, 33, 34];
    addNum = 4;
    sTitle = "组选六";
  }
  var dataLeng = showArr.length;
  
  strTbl += crt_btnSubid(subid, sTitle); // 显示前三 中三 后三 按钮
  strTbl += "<table style='border: 1px solid #c8c8c8;' width='100%' cellPadding='0'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>" +  subTitle[subid] + "◎" + sTitle + "</caption>";
  strTbl += "<tr class='title0 bgImg_" + myGlobalVal.gametype + "' id='titletype'>";
  for(i = 0; i < dataLeng; i++){
    j = i + addNum;
    setQuickUrl = " id='url_" +  showArr[i] + "_" + subid + "'";
    if( j < 10 ) { strTbl += "<th "+ setQuickUrl +" class='titleTypeBtnClick' >&nbsp;" + j + "&nbsp;</th>"; }
    else { strTbl += "<th>全包</th>"; }
  }
  strTbl += "</tr>";
  strTbl += "<tr>";
  
  for(i = 0; i < dataLeng; i++ ){
    oObj = eval("ratedata.r" + showArr[i] + "_" + subid);
    oObj_total = eval("ratedata.r" + showArr[i] + "_" + subid + "total");
    strTbl += "<td valign='top'>";
    strTbl += crt_g(oObj, oObj_total, "", showArr[i], subid, showArr[i]);
    strTbl += "</td>";
  }
  strTbl += "</tr></table>";
  $("#myDivTbl").html(strTbl);

}

// 一字过关  
function show_r1pass(_lotto_id, playtype, ratedata){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'><caption class='td0 bgClc_" + myGlobalVal.gametype + "'>一字过关</caption><thead><tr class='td6'><th>类别</th><th>合计</th><th colspan='6'>佰</th><th colspan='6'>拾</th><th colspan='6'>个</th></tr></thead>";
  strTbl += "<tbody class='td2' align='center'>";
  strTbl += "<tr class='td6'><th class='td6' rowspan='4'>一字过关</th><th class='span3dall' rowspan='4'>0</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th> <th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr>";
  strTbl += crt_1pass(ratedata.r46_0, ratedata.r46_0total, "", 46, 0, '一字过关');
  strTbl += "</tbody></table>";
  $("#myDivTbl").html(strTbl);
}

// 跨度
function show_r1bs(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>跨度</caption>";
  strTbl += myHeader;
  strTbl += crt_a_0To9(ratedata.r47_0, ratedata.r47_0total, "", 47, 0, "跨度", "");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
// 跨度 - 5码 前中后一起秀
function show_r1bs_n5(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>跨度</caption>";
  strTbl += myHeader;
  strTbl += crt_a_0To9(ratedata.r47_2, ratedata.r47_2total, "", 47, 2, "前三◎跨度", "");
  strTbl += crt_a_0To9(ratedata.r47_1, ratedata.r47_1total, "", 47, 1, "中三◎跨度", "");
  strTbl += crt_a_0To9(ratedata.r47_0, ratedata.r47_0total, "", 47, 0, "后三◎跨度", "");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 其他
function show_r1o(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += "<caption class='td0 bgClc_" + myGlobalVal.gametype + "'>其他</caption>";
  strTbl += myHeader;
  strTbl += crt_o([ratedata.r48_0,ratedata.r49_0, ratedata.r50_0, ratedata.r51_0, ratedata.r52_0]
                  , [ratedata.r48_0total, ratedata.r49_0total, ratedata.r50_0total, ratedata.r51_0total, ratedata.r52_0total]
                  , "", [48, 49, 50, 51, 52], [0, 0, 0, 0, 0], "其他");
  strTbl += crt_a_0To9(ratedata.r53_0, ratedata.r53_0total, "", 53, 0, "准对", "");
  strTbl += crt_a_0To9(ratedata.r54_0, ratedata.r54_0total, "", 54, 0, "不出牌", "");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 全部      
function show_all(_lotto_id, playtype, ratedata){
  _playtype = playtype;
  var strTbl = "";
  $("#myDivTbl").html(strTbl);
}

/*******************************简易版 table***********************************/
// 双面盘&龙虎和
function show_r1_n5s(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader_sr1;
  
  // 第 N 球-大小,单双
  var showTitleArr = ['单', '双', '大', '小'];
  var showTitleArr2 = ['总单', '总双', '总大', '总小'];
  var showTitleArr3 = ['龙', '虎', '和', ''];
  
  // 第一球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_1 , ratedata.r2_1] 
                        , [ratedata.r1_1total, ratedata.r2_1total]
                        , "", [1,2], [1,1], '第一球', showTitleArr);

  // 第二球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_2 , ratedata.r2_2]
                        , [ratedata.r1_2total, ratedata.r2_2total]
                        , "", [1,2], [2,2], '第二球', showTitleArr);
  
  // 第三球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_3 , ratedata.r2_3]
                        , [ratedata.r1_3total, ratedata.r2_3total]
                        , "", [1,2], [3,3], '第三球', showTitleArr);

  // 第四球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_4 , ratedata.r2_4]
                        , [ratedata.r1_4total, ratedata.r2_4total]
                        , "", [1,2], [4,4], '第四球', showTitleArr);
  
  // 第五球-单双,大小
  strTbl += crt_2face_com([ratedata.r1_5 , ratedata.r2_5]
                        , [ratedata.r1_5total, ratedata.r2_5total]
                        , "", [1,2], [5,5], '第五球', showTitleArr);
  
  // 总和-单双,大小
  strTbl += crt_2face_com([ratedata.r3_0, ratedata.r4_0]
                         , [ratedata.r3_0total, ratedata.r4_0total]
                         , "", [3, 4], [0,0], '总和', showTitleArr2);
  // 龙虎和
  strTbl += crt_2face_com([ratedata.r5_0]
                         , [ratedata.r5_0total]
                         , "", [5], [0], '龙虎和', showTitleArr3);
  $("#myDivTbl").html(strTbl);
}

// 定位
function show_r1p_n5s(_lotto_id, playtype, ratedata){
  var strTbl = "<table class='tblMy3D' width='990' >";
  strTbl += _myHeader_sr1p;
  strTbl += crt_0To9(ratedata.r0_1, ratedata.r0_1total, "", 0, 1, '第一球');
  strTbl += crt_0To9(ratedata.r0_2, ratedata.r0_2total, "", 0, 2, '第二球');
  strTbl += crt_0To9(ratedata.r0_3, ratedata.r0_3total, "", 0, 3, '第三球');
  strTbl += crt_0To9(ratedata.r0_4, ratedata.r0_4total, "", 0, 4, '第四球');
  strTbl += crt_0To9(ratedata.r0_5, ratedata.r0_5total, "", 0, 5, '第五球');
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}

// 其他
function show_r1os(_lotto_id, playtype, ratedata, myHeader){
  var strTbl = "";
  strTbl += "<table class='tblMy3D' width='990'>";
  strTbl += _myHeader_sr1p;
  strTbl += crt_o(ratedata.r6_2, ratedata.r6_2total, "", 6, 2, "前三其他");
  strTbl += crt_o(ratedata.r6_1, ratedata.r6_1total, "", 6, 1, "中三其他");
  strTbl += crt_o(ratedata.r6_0, ratedata.r6_0total, "", 6, 0, "后三其他");
  strTbl += "</table>";
  $("#myDivTbl").html(strTbl);
}
/*******************************简易版 table***********************************/

// -----------------------------------------------------------------------------
// 按了玩法执行结果
// -----------------------------------------------------------------------------
function clickTitle(playtype){
 $("#myDivNow").empty();
 $("#myDivTblTop").empty();
 $("#myDivTbl").empty();
 _playtype = playtype;
 $("form#frmMenu input#playtypestr").val(playtype);
 if(playtype == 'r2p'){
  $("form#frmMenu input#bid").val("14");  
 }else if(playtype == 'r2a'){
  $("form#frmMenu input#bid").val("36,39");
 }else{
  $("form#frmMenu input#bid").val("");
 }
 $("form#frmMenu input:hidden#order").val("2"); 
 $("th.cbig").removeClass('cbig');
 $("th#myThBar" + playtype).addClass('cbig');
 
 switch(playtype){
    case 'r3p':
    case 'rcmp':
      $("#myDivTblTop").html(crt_pGroup());
      $("form#frmMenu input:hidden#order").val("0");
      loadFunR3p();
      break;
    case 'r3': 
      // 前110名勾选
      $("#myDivTblTop").html(crt_btnGruopOrder());
      $("form#frmMenu input:hidden#order").val("0");
      $("#btnGruopOrder input:radio").click(function(){
        var valSlc = $("#btnGruopOrder input:radio:checked").index();
        if(valSlc == 0){ $("form#frmMenu input:hidden#order").val("0"); }
        else{ $("form#frmMenu input:hidden#order").val("2"); }
        $("input#btnReflash").click();
      });
      break;
     case 'r2p':
     case 'r2':
      $("form#frmMenu input:hidden#order").val("0");
      break;
     case 'r1pass':
      $("#myDivTblTop").html('<input type="hidden" name="unow46_0[]" value="" id="specUnow46_0" />');
      $("form#frmMenu input:hidden#order").val("2");
      break;
    default: $("#myDivNow").text(''); break;
 }
 var btnrate3DCK = $().getCookie(playtype+'BtnRate3DCK','');
 var btnBack3DCK = $().getCookie(playtype+'BtnBack3DCK','');
 var btnAmount3DCK = $().getCookie(playtype+'BtnAmount3DCK','');
 $("form#frmCheckUnow input#BtnRate").val([btnrate3DCK]);
 $("form#frmCheckUnow input#BtnBack").val([btnBack3DCK]);
 $("form#frmCheckUnow input#BtnAmount").val([btnAmount3DCK]);
 $("input#btnReflash").click();
}

// 三字组合 勾选画面
function crt_btnGruopOrder(){
  var str = "";
  str = '<br /><span id="btnGruopOrder" class="msgBox-yellow">';
  str += '<label><input type="radio" value="0" name="pFlag" checked="checked" />前110名(输赢排序)</label>';
  str += '<label><input type="radio" value="1" name="pFlag" />号码(排序)000~234</label>';
  str += '<label><input type="radio" value="2" name="pFlag" />号码(排序)235~999</label>';
  str += '</span>';
  str += '<input type="hidden" name="listnum" value="110" />';
  return str;
}

// 三字定位、复式组合 勾选画面
function crt_pGroup(){
  var strTbl = "";
  strTbl += "<label class='bgClc_" + myGlobalVal.gametype + "'><input type='checkbox' value='100' name='listnum2' id='listnum2' checked='true' />仅显示前100名(输赢排序)</label>";
  strTbl += "<div id='pGroup' class='bgClc_" + myGlobalVal.gametype + "' style='display:none;text-align:left'><span style='background-color:#feffcd;' id='ptypeGroup'>定位别(号码排序)：";
  strTbl += "<label><input type='radio' value='0' name='ptype' checked='checked' />佰</label>";
  strTbl += "<label><input type='radio' value='1' name='ptype' />拾</label>";
  strTbl += "<label><input type='radio' value='2' name='ptype' />个</label>";
  strTbl += "</span>&nbsp;&nbsp;&nbsp;";
  strTbl += "<span id='pnumGroup'>定位数：";
  strTbl += "<label><input type='radio' value='0' name='pnum' checked='checked' />0</label>";
  strTbl += "<label><input type='radio' value='1' name='pnum' />1</label>";
  strTbl += "<label><input type='radio' value='2' name='pnum' />2</label>";
  strTbl += "<label><input type='radio' value='3' name='pnum' />3</label>";
  strTbl += "<label><input type='radio' value='4' name='pnum' />4</label>";
  strTbl += "<label><input type='radio' value='5' name='pnum' />5</label>";
  strTbl += "<label><input type='radio' value='6' name='pnum' />6</label>";
  strTbl += "<label><input type='radio' value='7' name='pnum' />7</label>";
  strTbl += "<label><input type='radio' value='8' name='pnum' />8</label>";
  strTbl += "<label><input type='radio' value='9' name='pnum' />9</label>";
  strTbl += "</span></div>";
  strTbl += "<input type='hidden' name='pFlag' id='pFlag' value='0' />";
  strTbl += '<input type="hidden" name="listnum" value="100" />';
  return strTbl;
}

// 三字定位, 复式组合 画面专用function
function loadFunR3p(){
  // 前100名 勾选
  $("input:checkbox#listnum2").click(function(){
    $(this).attr("disabled","disabled");
    if($(this).attr("checked")){
      $("#pGroup").css("display", "none");
      $("form#frmMenu input:hidden#order").val("0");
      $("form#frmMenu input:hidden#pFlag").val("0");
    }else{
      $("#pGroup").css("display", "");
      $("form#frmMenu input:hidden#order").val("2");
      $("form#frmMenu input:hidden#pFlag").val("1");
    }
    $("input#btnReflash").click();
  });
  
  // change play type mode by click 
  $("span#ptypeGroup input:radio").add("span#pnumGroup input:radio").click(function(){
    $("input#btnReflash").click();
  });
  
}

// do unow bettype_subid
$.fn.addUnowData = function(){
  var playtype = $("form#frmMenu input#playtypestr").val();
  var btnrate = $("form#frmCheckUnow input#BtnRate").val();
  var btnBack = $("form#frmCheckUnow input#BtnBack").val();
  var btnAmount = $("form#frmCheckUnow input#BtnAmount").val();
  if(btnrate == ""){alert('请输入赔率'); return false;}
  else if(btnAmount == ""){alert('请输入金额'); return false;}
  else if($("div#myDivTbl input:checkbox:checked").size() < 1){
    alert('请勾选号码');
    return false;
  }
  
  $().setCookie(playtype+"BtnRate3DCK",btnrate);
  $().setCookie(playtype+"BtnBack3DCK",btnBack);
  $().setCookie(playtype+"BtnAmount3DCK",btnAmount);
  var msg = "走飞内容\n -------------------- \n";
  var cn = 0;
  var chkVal = 0;
  var r1passFlag = false;
  if(playtype != 'r1pass'){
    $("div#myDivTbl input:checkbox:checked").each(function(idx, ele){
      var titleStr = $(this).attr('name');
      titleStr = titleStr.substr(4, (titleStr.length - 6));
      msg = msg + "[" + uTitle[titleStr] + "]" + $(this).getBetNumName(titleStr) + " -> " + btnAmount + "\n";
      cn++;  
    });
  }else{
    var numArr = new Array(); 
    $("div#myDivTbl input:checkbox:checked").each(function(idx, ele){
      numArr.push($(ele).val());
      return true; 
    });
    if(numArr.length != 3){ alert('勾选个数错误, 无法走飞!'); return false;}
    else{ 
      numArr.sort(sortNumber);
      chkVal = numArr[0]; 
      if(chkVal < 0 || chkVal > 5){ alert('佰位数未勾选!'); return false; }
      chkVal = numArr[1] - 6;                        
      if(chkVal < 0 || chkVal > 5){ alert('拾位数未勾选!'); return false; }
      chkVal = numArr[2] - 12;                       
      if(chkVal < 0 || chkVal > 5){ alert('个位数未勾选!'); return false; }
      var titleStr = '46_0';
      cn++;
      $('#specUnow46_0').val(numArr.join(','));
      msg = msg + "[" + uTitle[titleStr] + "]" + $('#specUnow46_0').getBetNumName(titleStr) + " -> " + btnAmount + "\n";
      r1passFlag = true;
    }
  }
  msg = msg + " -------------------- \n 合计" + cn + '笔' + " \n\n 是否确定走飞?";
  if(confirm(msg)){
    if(r1passFlag){  $("div#myDivTbl input:checkbox").removeAttr('checked'); } 
    $.ajax({
      type: 'POST',
      url: 'op.php?op=admin&fp=xmlAddUnow_3d',
      dataType: 'json',
      data: $("form#frmMenu").serialize()+ "&" + $("form#frmCheckUnow").serialize(),
      success: function(rdata){
        if(rdata.msg=="OK"){
           setTimeout(function(){$("form#frmMenu input#btnReflash").click();},1000);
           alert('走飞完成！因更新资料需要时间,若画面未即时更新,请稍等一下,谢谢。');
        }else{
           alert("error:" + rdata.msg);
        }
      }
    });
  }
};

// get the bet name of number
$.fn.getBetNumName = function(titleStr){
  // alert(titleStr);
  var titleStrArr = titleStr.split("_");
  if(titleStrArr.length != 2){ return '- error -'; }
  var bettype = titleStrArr[0];
  var subid = titleStrArr[1];
  var num = $(this).val();
  
  if(myGlobalVal.simple){ // 简易版
    switch(bettype){
      case '0':
        return num;
        break;
        
      case '1':
        var tempArr = [ '', '单','双'];
        return tempArr[num];
        break;
        
      case '2':
        var tempArr = [ '', '大','小'];
        return tempArr[num];
        break;
        
      case '3':    
        var tempArr = ['','总单','总双'];
        return tempArr[num];
        break;
        
      case '4':    
        var tempArr = ['','总大','总小'];
        return tempArr[num];
        break;
        
      case '5':    
        var tempArr = ['','龙','虎','和'];
        return tempArr[num];
        break;
        
      case '6':
        var tempArr = ['豹子','顺子','对子','半顺','杂六'];
        return tempArr[num];
        break; 
    }
  }
  else{        
    switch(bettype){
        case '21':
        case '0':
  	    case '1':
  	    case '2':
  	    case '3':
  	    case '47':
  	    case '53': 
        case '54':
        case '55':    
        case '69':
        case '70':
        case '14':
        case '15':
        case '16': 
        case '13':
        case '20':
        
              // 组选三5-9 组选六 4-8 三字组合
        case '24':
      	case '25':
      	case '26':
      	case '27':
      	case '28':
      	case '30':
        case '31':
        case '32':
        case '33':
        case '34':
        case '35':  // 复式组合
        return num;
        break;
  	    
  	    case '39':
        case '40':
        case '41': 
        case '43':     
        return num + " 尾";
        break;
        
        case '4':
  	    case '5':
  	    case '6':
  	    case '22':
  	    case '56':
  	    case '59':    
        var tempArr = ['','大','小'];
        return tempArr[num];     
        break;
        
        case '44':
        var tempArr = ['', '尾大', '尾小'];
        return tempArr[num];     
        break;
        
   
  	    case '7':
  	    case '8':
  	    case '9':
  	    case '17':
  	    case '18':
  	    case '19':
  	    case '23':
  	    case '60':
  	    case '57':   
        case '62': 
        case '63':
        case '64':
        case '65':
        case '66':
        case '67':
        case '68':
        var tempArr = [ '', '单','双'];
        return tempArr[num];
        break;
  
        case '10':
  	    case '11':
  	    case '12':
  	    case '58':
  	    case '61':    
        var tempArr = ['','质','合'];
        return tempArr[num];
        break;
        
        case '45': 
        var tempArr = ['','尾质','尾合'];
        return tempArr[num];
        break;
        
        // 组三全包
        case '29':
        $reVal = "全包";
        break;
        
        case '36': // 佰拾和数
        case '37': // 佰个和数
        case '38': // 拾个和数
        if(num == "4"){ return "0~4"; }
        else if(num == "14"){ return "14~18"; }
        else{ return num; }
        break;
        
        case '42': // 佰拾个和数      
        if(num == "6"){ return "0~6"; }
        else if(num == "21"){ return "21~27"; }
        else{  return num; }
        break;
        
        case '46': //一字过关
        var numArr = num.split(",");
        var idx0 = numArr[0]; 
        var idx1 = numArr[1];
        var idx2 = numArr[2];
        var tempArr = ['佰大', '佰小', '佰单', '佰双', '佰质', '佰合', '拾大', '拾小', '拾单', '拾双', '拾质', '拾合', '个大', '个小', '个单', '个双', '个质', '个合'];
        return tempArr[idx0] + 'X' + tempArr[idx1] + 'X' + tempArr[idx2];
        break;
        
        case '48': return "豹子"; break;  //豹 
        case '49': return "顺子"; break; 
        case '50': return "对子"; break; 
        case '51': return "半顺"; break; 
        case '52': return "杂六"; break;
        break; 
        case '71':    
        var tempArr = ['','总单','总双'];
        return tempArr[num];
        break;
        case '72':    
        var tempArr = ['','总大','总小'];
        return tempArr[num];
        break;
        case '73':    
        var tempArr = ['','龙','虎','和'];
        return tempArr[num];
        break;
		case '74':    
        var tempArr = ['','牛1','牛2','牛3','牛4','牛5','牛6','牛7','牛8','牛9','牛牛','牛大','牛小','无牛','牛单','牛双'];
        return tempArr[num];
        break;
		case '75':    
        var tempArr = ['','五条','四条','葫芦','顺子','三条','两对','单对','散号'];
        return tempArr[num];
        break;
     }
   }
   return '-null-';
};


function sortNumber(a, b){ return a - b; }



// -----------------------------------------------------------------------------
// for unow page
// -----------------------------------------------------------------------------

$(function(){

  nowdate();
  countdown();

  // raterecord -- over page
  $("input:button#btnRateRecord").click(function(){
    showRateRecordPage(myGlobalVal.gametype, myGlobalVal.open)  
  });  
  
  // button of reload, just reflash rates instade of reload all page
  $("input#btnReflash").click(function(){ $("span#reflashtimeMin").text('30'); $(this).getAjaxDataAuto(_playtype, __roundID);$("form#frmMenu input").attr("disabled","true"); });
  
  // my (255) data of fly
  $("input#btnShowBet2").click(function(){
     var showUrl = "?op=admin&fp=bet8list_3d&showType=1&dates=&datee=" + myGlobalVal.open + "&num=all&gametype=" + myGlobalVal.gametype + "&lid=" + myGlobalVal.lotto_id_3d;
     window.open(showUrl,'_blank','scrollbars=yes,width=800,height=600');
  });
  
  // 走飞 -- 二面
  $("form#frmCheckUnow input:button#btnDoUnow").bind('click',function(){
    $().addUnowData();
  });
  clickTitle(myGlobalVal.playtypestr);
  
});